50
List in classes
Point(const Point &from) {
_x = from._x;
_y = from._y;
}
void setX(const int val);
void setY(const int val);
int getX() { return _x; }
int getY() { return _y; }
};
class Point {
int _x, _y;
public:
Point() {
_x = _y = 0;
}
Point(const int x, const int y) {
_x = x;
_y = y;
}
In class Point a third constructor which takes care of correctly copying values from one object to the newly created one is added.
The third constructor takes a constant reference to an object of class Point as an argument and assigns _x and _y the corresponding values of the provided object.

| If we want to create a point from another point, hence, copying the properties of one object to a newly created one, we sometimes have to take care of the copy
| process. For example, consider the class List which allocates dynamically memory for its elements. If we want to create a second list which is a copy of the first, we
| must allocate memory and copy the individual elements.
| This type of constructor is so important that it has its own name: copy constructor. It is highly recommended that you provide for each of your classes such a
| constructor, even if it is as simple as in our example. The copy constructor is called in the following cases:
| Point apoint; // Point::Point()
| Point bpoint(apoint); // Point::Point(const Point &)
| Point cpoint = apoint; // Point::Point(const Point &)
| With help of constructors we have fulfilled one of our requirements of implementation of abstract data types: Initialization at definition time. We still need a
| mechanism which automatically “destroys'' an object when it gets invalid (for example, because of leaving its scope). Therefore, classes can define destructors.